<?php
//base
$id				= gpc_getIntPost("id",$id);
$name	        = gpc_getStringPost("Name");
$urlstring		= gpc_getStringPost("URL",$name);
$title			= gpc_getStringPost("Title",$name);
$code   		= gpc_getStringPost("Code");
$parentId       = gpc_getIntPost("ParentId");
$parentId2      = gpc_getIntPost("ParentId2");
$listLocation   = gpc_getStringArray('listLocation');
$Status 		= gpc_getIntPost("Status");
$TopBottomOrder	= gpc_getIntPost("TopBottomOrder",-1);
$order 			= gpc_getIntPost("Order",-1);
$tag            = gpc_getStringPost('Tag');
$ImgIntro 		= gpc_getStringPost('ImgIntro');
$ImgBanner 		= gpc_getStringPost('ImgBanner');

//meta:
$metatitle 		= gpc_getStringPost("MetaTitle",$name);
$metakeywords 	= gpc_getStringPost("MetaKeywords");
$metadescription= gpc_getStringPost("MetaDescription",strip_tags($description));

//tour
$Days        	= gpc_getStringPost("Days");
$HighLights   	= gpc_getStringPost("HighLights");
$PriceFrom    	= gpc_getStringPost("PriceFrom");
$Summary 	    = gpc_getStringPost("Summary");
$FullItinerary 	= gpc_getStringPost("FullItinerary");
//$RoutesName 	= gpc_getStringPost("RoutesName");
//$Activities		= gpc_getStringPost("Activities");
//$Brieft			= gpc_getStringPost("Brieft");
$PriceBoad		= gpc_getStringPost("PriceBoad");
//$WhatToBringItems= gpc_getStringPost("WhatToBringItems");
//$Inclusion		= gpc_getStringPost("Inclusion");
//$Exclution		= gpc_getStringPost("Exclution");

//------==============-------------------
$urlstring      = Trim_Url($urlstring);

if(empty($name))
{
	error_transfer("Name Tour is empty!");
}

$Brieft      = replace_pathlocal($Brieft);
$Intro		 = replace_pathlocal($Intro);
$metadescription=strip_tags($metadescription);

//check url:
CheckUrlString($urlstring,"tblsettour");

$order  = GetOrderForInsert($TopBottomOrder,$order,$parentId,"tblsettour");

if($act=="insert")
{
    $poster     = getUserNamePost();
    
    $sql_insert = "INSERT INTO tblsettour
    (iParentId,iParentId2,cUrlString,cName,cCode,cImage,cBanner,
    cDays,cHighLights,cPriceFrom,cSummary,cFullItinerary,cPriceDayArr,
    dPostDate,cPoster,iViewTimes,iStatus,iOrder,cMetaTitle,cMetaDescription,cMetaKeywords,cLanguage)
    
    VALUES('$parentId','$parentId2','$urlstring','$name','$code','$ImgIntro','$ImgBanner',
    '$Days','$HighLights','$PriceFrom','$Summary','$FullItinerary','$PriceBoad',
    '$postdate','$poster','0','$Status','$order','$metatitle','$metadescription','$metakeywords','$language')";
    
    $dbsql->query($sql_insert);
    
    $id   = $dbsql->insert_id();
    
    UpdateMapLocationId($listLocation,$id);

    Insert_Tracking("Add Tour : $name ");
    page_transfer("Add Tour Success",getUrlBack());
    //page_transfer("Add Tour Success !","opt=addcontent&id=$idtour");
    
}
elseif($id>0)
{
    
    $sql_update = "UPDATE tblsettour SET ";
    $sql_update.= "iParentId        = '$parentId', ";
    //$sql_update.= "iParentId2       = '$parentId2', ";
    $sql_update.= "cUrlString       = '$urlstring', ";
    $sql_update.= "cName            = '$name', ";
    $sql_update.= "cCode            = '$code', ";
    $sql_update.= "cImage           = '$ImgIntro', ";
    $sql_update.= "cBanner          = '$ImgBanner', ";
    $sql_update.= "cDays            = '$Days', ";
    $sql_update.= "cHighLights      = '$HighLights', ";
    $sql_update.= "cPriceFrom       = '$PriceFrom', ";
    $sql_update.= "cSummary         = '$Summary', ";
    $sql_update.= "cFullItinerary   = '$FullItinerary', ";
    $sql_update.= "cPriceDayArr     = '$PriceBoad', ";

    $sql_update.= "iStatus          = '$Status', ";
    if($order>0)
    {
        $sql_update.= "iOrder       = '$order', ";
    }
    $sql_update.= "cMetaTitle       = '$metatitle', ";
    $sql_update.= "cMetaDescription = '$metadescription', ";
    $sql_update.= "cMetaKeywords    = '$metakeywords' ";
    $sql_update.= "where iId        = $id";

    $dbsql->query($sql_update);
    
    UpdateMapLocationId($listLocation,$id);

    Insert_Tracking( " Edit Tour : $name ");
    page_transfer("Update Tour Success",getUrlBack());
}
exit();
?>